<extend name="common/base" />
<block name="resource">
    <link href="__PUBLIC__/Home/ui3/css/share.css?v=1.0.3" rel="stylesheet">
    <!-- 表情核心JS -->
    <script src="__PUBLIC__/Home/ui3/js/face.js" type="text/javascript"></script>
    <!-- 分页JS -->
    <script src="__PUBLIC__/Home/ui3/js/web/paging.js" type="text/javascript"></script>
    <!-- 替换表情文字 -->
    <script src="__PUBLIC__/Home/ui3/js/web/emotion.js?v=1.0" type="text/javascript"></script>
    <script src="__PUBLIC__/Home/ui3/js/web/scroll.js?v=1.0" type="text/javascript"></script>

    <script src="__PUBLIC__/Home/ui3/js/web/share/comment.js?v=1.0.1" type="text/javascript"></script>
    <script src="__PUBLIC__/Home/ui3/js/web/home/recommend.js?v=1.0.2" type="text/javascript"></script>
    <script src="__PUBLIC__/Home/ui3/js/zclip/jquery.zclip.min.js"></script>
    <script src="__PUBLIC__/Home/ui3/js/jwplayer/jwplayer.js?v=1.0"></script>
    <script src="__PUBLIC__/Home/ui3/js/web/share/video.js?v=1.0.1"></script>

    <script language="javascript">
        if (window.parent != window.self) {
            location.href = "{:U('VideoPlay/index', ['id' => $video['id']])}";
        }
        window._THIS = {
            videoLink : "{:U('share/video')}",
            userLink : "{:U('Others/index')}",
            recommendUrl : "{:U('share/video', ['id' => $video['id']])}",
            likeUrl : {
                dolike : "{:U('like/dolike')}",
                unlike : "{:U('like/unlike')}",
            },
            followUrl : {
                dofollow : "{:U('follow/dofollow')}",
                unfollow : "{:U('follow/unfollow')}",
            },
            commentUrl : {
                get : "{:U('video/getCommentList')}",
                post : "{:U('video/comments')}",
            },
            commentPager : 20,
            video : {$video|json_encode},
        };
        $(function(){
            initJwplayer();
            window._bd_share_config = {
                "common": {
                    "bdSnsKey": {},
                    "bdText": "",
                    "bdMini": "2",
                    "bdMiniList": false,
                    "bdPic": "",
                    "bdStyle": "0",
                    "bdSize": "16",
                    onBeforeClick:function(cmd,config){
                        return {
                            bdUrl:_COMMON.DOMAIN + "{:U('share/video', ['id' => $video['id']])}" + "?type=share",
                            bdText:"{$video.title}",
                            bdPic:"{$video.thumb}"
                        };
                    }
                },
                "share": {},
                "image": {"viewList": ["qzone", "tsina", "tqq", "weixin"], "viewText": "分享自：66Play", "viewSize": "16"},
            };
            with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
        });

        //伐木累分享
        var famulei_share = function(){
            var video_url = _COMMON.DOMAIN + '/api/video/source/id/{$video.id}.mp4?uri=' + encodeURIComponent("{$video.uri}") + '&from=famulei';
            var url = 'http://www.famulei.com/share_publish';
                url += '?title=' + encodeURIComponent("{$video.title}");
                url += '&video_url=' + encodeURIComponent(video_url);
                url += '&video_image=' + encodeURIComponent("{$video.thumb}");
            window.open(url);
        }

        function dataInit() {
            var self = {$userInfo|json_encode};
            if (self) {
                viewModel.self({
                    'id' : self.id ? self.id : 0,
                    'avatar' : self.avatar ? self.avatar : _COMMON.DEFAULT_AVATAR,
                    'nickname' : self.nickname,
                });
            }

            var videoData = {$video|json_encode};

            viewModel.video(getVideo(videoData));
            $(".copy-btn").zclip({
                path: _COMMON.PUBLIC + "/Home/ui3/js/zclip/ZeroClipboard.swf",
                beforeCopy:function(){
                    /* 按住鼠标时的操作 */
                },
                copy: function(){
                    return $('#iframecode').val();
                },
                afterCopy:function(){
                    /* 复制成功后的操作 */
                    alert('复制成功');
                }
            });

            var recommendData = {$about_videos|json_encode};
            viewModel.recommendList(getRecommend(recommendData));
            changeCommentPage(1, null);
        }
        function  initJwplayer() {
              jwplayer("mod_player").setup({
                flashplayer: _COMMON.PUBLIC+"/Home/ui3/js/jwplayer/jwplayer.flash.swf",
                image: "{$video.thumb}",
                // file: "{$video.uri}",
                controlbar: "over",  //控制条位置
                screencolor: "#fff",   //播放器颜色
                // stretching: "fill",    //画面自适应
                repeat:false,       //重复播放
                autostart:true,         //自动播放
                //mute: true,             //静音
                events:{
                    onComplete: function(e){ 
                       $(".popbg").show();
                       $("#myPopup").show();
                    },
                    onReady:function(){
                    },
                   onPlay: function(){
                        $.get("{:U('api/video/setPlay', ['id' => $video['id'], 'appid' => $appid])}");
                     }
                    // onVolume: function(){ alert("声音大小改变!!!"); },
                    // onReady: function(){console.log("准备就绪!!!"); },
                    // onPause: function(){ alert("暂停!!!");}
                },
                sources: getVideoSource(_THIS.video),
                width:"100%",
                aspectratio: "16:9",
                // modes: [
                //   { type: 'html5' },
                //   { type: 'flash', 'src': 'jwplayer.flash.swf' },
                //   { type: 'download' }
                // ]
            });
        }
    </script>
</block>

<block name="content">
<div class="main">
    <div class="container">
        <div class="share-left" data-bind="with:video">
            <include file="Template/banner_video" />
            <div class="video-box">
                <div class="video-info">{$video.title}</div>
                <div class="mod_player relative">
                    <div id="mod_player"></div>
                    <!--视频播放完成弹窗S-->
                    <div id="myPopup">
                        <div class="row">
                            <div class="col-xs-8 related-videos">
                                <h1>相关视频</h1>
                                <ul data-bind="foreach:viewModel.recommendList()">
                                    <!-- ko if: $index() < 4 -->
                                    <li>
                                        <a href="" data-bind="attr:{'href':link}">
                                            <div class="related-video-img relative">
                                                <img src="" data-bind="attr:{'src':thumb}"/>
                                                <span class="related-video-name" data-bind="text:title"></span>
                                            </div>
                                        </a>
                                    </li>
                                    <!-- /ko -->
                                </ul>
                            </div>
                          <div class="col-xs-4 row-right relative">
                              <h1>下载66Play APP 精彩不错过</h1>
                              <p><img src="__PUBLIC__/Home/ui3/images/66play-ma.jpg"/></p> 
                              <span class="replay" onclick="Videoreplay()"><img src="__PUBLIC__/Home/ui3/images/replay.png"/>重播</span>
                          </div>
                        </div>
                    </div>
                    <div class="popbg" onclick="hid()"></div>
                    <!--视频播放完成弹窗E-->
                </div>
                <div class="video-share">
                    <div class="share-logo"></div>
                    <div class="video-share-span">分享到：</div>
                    <div id="share">
                        <div class="bdsharebuttonbox">
                            <a class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
                            <a class="bds_tsina"data-cmd="tsina"title="分享到新浪微博"></a>
                            <a class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
                            <a class="bds_weixin"data-cmd="weixin"title="分享到微信"></a>
                            <a class="bds_other" data-bind="click:famulei_share" title="分享到伐木累"></a>
                        </div>
                    </div>
                    <div class="iframesrc">
                        <span class="colorsix">嵌入代码</span>
                        <input id="iframecode" type="text" value="" data-bind="value:copy" readonly="true"/>
                        <button class="copy-btn">复制</button>
                    </div>
                    <div class="" data-bind="click:doLike, css:{'video-zaned':zan.is_zan(), 'video-zan':!zan.is_zan()}">
                        <span class="zan-img"></span>
                        <span class="zan-num">赞：<!-- ko text:zan.count --><!-- /ko --></span>
                    </div>
                    <div class="video-hot">播放次数：<!-- ko text:playCount --><!-- /ko --></div>
                </div>
            </div>
            <div class="author-box">
                <div class="avatar relative">
                    <a href="{:U('Others/index', ['uid' => $video['user']['id']])}">
                        <img src="" alt="{$video.user.nickname}" data-bind="attr:{'src':user.avatar}"/>
                        <!-- ko if:user.auth -->
                            <img src="" title="" class="newG-icon" data-bind="attr:{'src':user.auth.pic, 'title':user.auth.name}">
                        <!-- /ko -->
                    </a>
                </div>
                <div class="author-infos">
                    <div class="author-info">
                        <div class="author-nick">
                            <a href="{:U('Others/index', ['uid' => $video['user']['id']])}">{$video.user.nickname}</a>
                        </div>
                        <div class="level">Lv.{$video.user.level}</div>
                    </div>
                    <div class="author-tips">
                        <span>视频:</span>
                        <span>{$video.user.tradeCount}</span>
                        <span>粉丝:</span>
                        <span data-bind="text:user.fans"></span>
                    </div>
                    <div class="followBtn" data-bind="visible:viewModel.self().id != user.id">
                        <button class="my-info-status" data-bind="text:user.is_follow()?'已关注':'关注', click:doFollow, css:{statusTwo:!user.is_follow(), statusOne:user.is_follow()}"></button>
                    </div>
                </div>
                <div class="game-box">
                    <div class="game-info">
                        <span>所属游戏：</span>
                        <span class="game-kind"><a href="javascript:void(0);">{$video.game.name}</a></span>
                        <span>上传于：</span>
                        <span>{$video.create_time|date="Y-m-d",###}</span>
                    </div>
                    <div class="game-infos">视频简介：{$video.detail|default=$video['title']}</div>
                </div>
            </div>
            <div class="comment-box JS_comment_top">
                <div class="comment-title">
                    <span>全部评论</span>
                    <span>(<!-- ko text:viewModel.commentCount --><!-- /ko -->条)</span>
                    <span class="write-comment"><a href="#myComment">写评论</a></span>
                </div>
                <div class="comment-box">
                    <div class="load-more" data-bind="visible:viewModel.commentLoading()">
                        <i><img src="__PUBLIC__/Home/ui3/images/loading-white.gif" alt="正在加载，请稍候..."/></i>
                        <span>正在加载，请稍候...</span>
                    </div>
                    <div class="comment-list" data-bind="foreach:viewModel.commentList()">
                        <div class="comment-item JS-comment_item">
                            <div class="comment-avatar relative">
                                <a href="javascript:void(0);" data-bind="attr:{'href':isValidUser ? userLink : 'javascript:void(0);'}">
                                    <img src="" alt="" data-bind="attr:{'src':avatar, 'alt':nickname}"/>
                                    <!-- ko if:auth -->
                                    <img src="" title="" class="newG-icon" data-bind="attr:{'src':auth.pic, 'title':auth.name}">
                                    <!-- /ko -->
                                </a>
                            </div>
                            <div class="comment-user">
                                <div class="nl">
                                    <div class="comment-n"><a href="javascript:void(0);" data-bind="attr:{'href':isValidUser ? userLink : 'javascript:void(0);'}, text:nickname"></a></div>
                                    <div class="comment-l" data-bind="text:level">LV.0</div>
                                </div>
                                <div class="comment-content" data-bind="html:content"></div>
                                <div class="comment-tips">
                                    <span class="floor" data-bind="text:floor"></span>
                                    <span class="c-time" data-bind="text:create_time"></span>
                                    <!-- ko if:isValidUser-->
                                    <span class="reply" data-bind="click:reply.show">回复TA</span>
                                    <!-- /ko -->
                                    <span class="from">来自66play网页</span>
                                </div>
                                <div class="reply-comment JS-comment_box">
                                    <div class="comment-avatar">
                                        <a href="javascript:void(0);">
                                            <img src="" alt="" data-bind="attr:{'src':viewModel.self().avatar, 'alt':viewModel.self().nickname}"/>
                                        </a>
                                    </div>
                                    <div class="reply-box">
                                        <div class="top-arr"></div>
                                        <textarea id="" data-bind="attr:{'id':'comment_c_'+id}" placeholder="发表你的评论吧！"></textarea>
                                        <div class="r-sb ">
                                            <i class="emotion"></i>
                                            <input type="button" value="发表" class="rp btn myBtn" data-bind="click:postComment"/>
                                            <input type="button" value="取消" class="rc btn btn-default" data-bind="click:reply.hide"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="clearflaot"></div>
                        </div>
                    </div>
                    <div class="comment-null" data-bind="visible:viewModel.commentCount() < 1">
                        <div class="null-pic"></div>
                        <p>还没有人评论过</p>
                        <p>沙发虚位以待，快来抢吧！</p>
                    </div>
                    <div class="page">
                        <ul data-bind="visible: viewModel.commentPaging().length > 1, foreach:viewModel.commentPaging">
                            <li data-bind="css:{'active': is_current, 'next':is_next}, click:click">
                                <a href="javascript:void(0);" data-bind="text:text"></a>
                            </li>
                        </ul>
                    </div>
                    <div class="myComment" id="myComment">
                        <div class="myComment-title">写评论</div>
                        <div class="myComment-write">
                            <div class="comment-avatar">
                                <a href="javascript:void(0);">
                                    <img src="" alt="" data-bind="attr:{'src':viewModel.self().avatar, 'alt':viewModel.self().nickname}"/>
                                </a>
                            </div>
                            <div class="reply-box JS-comment_box">
                                <textarea id="JS_comment_a" placeholder="发表你的评论吧！"></textarea>
                                <div class="r-sb ">
                                    <i class="emotion"></i>
                                    <input type="button" value="发表" class="rp btn myBtn" data-bind="click:postComment"/>
                                    <!--<input  type="button" value="取消" class="rc btn btn-default"/>-->
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="share-right">
            <div class="video-info">
                <span class="title">热门推荐</span>
                <span class="change" data-bind="click:changeRecommend">换一批</span>
            </div>
            <div class="recommend-box" data-bind="foreach:recommendList">
                <div class="recommend-item-list JS_recommend">
                    <a href="" data-bind="attr:{'href':link}, event:{mouseover:play, mouseout:pause}">
                        <div class="item-video">
                            <video class="myVideo" style="background: rgba(0, 0, 0, 1) none repeat scroll 0 0;" src="" poster="" data-bind="attr:{'poster':thumb, 'src':src}"></video>
                            <div class="game">
                                <!-- <span class="game-kinds"></span> -->
                                <span class="game-name" data-bind="text:game_name"></span>
                                <span class="game-time" data-bind="text:time"></span>
                            </div>
                        </div>
                        <div class="item-details" data-bind="text:title"></div>
                        <div class="item-info">
                            <div class="item-nickname">
                                <i class="nick-icon"></i>
                                <div class="nick" data-bind="text:nickname"></div>
                            </div>
                            <div class="item-play">
                                <i class="play-icon"></i>
                                <div class="play-num">播放<!-- ko text:playCount --><!-- /ko --></div>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
</block>